//
//  MyTableViewController.m
//  Test
//
//  Created by 祝文博 on 15/3/5.
//  Copyright (c) 2015年 KevinLab. All rights reserved.
//

#import "MyTableViewController.h"

@interface MyTableViewController ()

@end

@implementation MyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
//    self.edgesForExtendedLayout = UIRectEdgeNone;
//    NSLog(@"frame : %@", NSStringFromCGRect(self.tableView.frame));
}

- (void)viewDidAppear:(BOOL)animated {
    
    [super viewDidAppear:animated];
//    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
//    self.tableView.delegate = self;
//    self.tableView.dataSource = self;
//    NSLog(@"frame : %@", NSStringFromCGRect(self.tableView.frame));
    
    //UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
//    [self.view addSubview:self.tableView];
    CGRect rect = self.tableView.frame;
    rect.size.height -= 49;
    self.tableView.frame = rect;
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return 15;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellTableIdentifier = @"cellTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellTableIdentifier];
    
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellTableIdentifier];
        
        CGRect nameLabelRect = CGRectMake(45, 15, 70, 15);
        UILabel *nameLabel = [[UILabel alloc] initWithFrame:nameLabelRect];
        nameLabel.text = @"this is a title";
        nameLabel.font = [UIFont boldSystemFontOfSize:12];
        
        [cell.contentView addSubview:nameLabel];
        
        UIImage *image = [UIImage imageNamed:@"tab_icon_1"];
        cell.imageView.image = image;
    }
    return cell;
}

@end
